#include <string.h>
#include <stdio.h>
#include "Personnel.h"
void liste_Personnel(char A[])
{
Personnel P;
FILE *f;
f=fopen(A,"rb");
while (!feof(f))
fread(&P,sizeof(Personnel),1,f);
fclose(f);
}
int Rechercher_Personnel(char *A,char *nom) 
{


  char c;
  int found=0;
  int pos=0;
  int length;

  FILE *f;
  f = fopen(A,"rb");
  if( f == NULL )
    return 0;

  length=strlen(nom);

  while( fread(&c,sizeof(Personnel),1,f)>0 && !found ) {

    if( c==nom[pos] ) {
      pos++;
    } else {
      if(pos!=0) {
        
        fseek(f,-pos,SEEK_CUR);
        pos=0;
      }
    }

    found = (pos==length);

  }
  fclose(f);

  return found;

}
void enregistrer_Personnel(char A[],Personnel * P)
{
FILE*f;
f=fopen(A,"ab");
fwrite(&P,sizeof(Personnel),1,f);
fclose(f);
}
void saisir_Personnel(Personnel*P)
{
printf("donner le nom");
scanf("%s",(*P).nom);
printf("donner le prènom");
scanf("%s",(*P).prènom);
printf("donner CIN");
scanf("%ld",(*P).CIN);
}
